<title>物料数据</title>
<link rel="stylesheet" href="/static/public/vendor/select2/select2.css">

<script src="/static/public/vendor/select2/select2.min.js" data-name="select2"></script>
<script src="/static/public/vendor/select2/i18n/zh-CN.min.js" data-deps="select2"></script>
<div class="page-content">
    <div class="collapse in" id="collapseFilter" aria-expanded="true">
        <div class="panel">
            <div class="panel-body">
                <form class="form-inline" id="projectForm">
                    <div class="form-group">

                    </div>
                    <div class="form-group">

                    </div>
                </form>

            </div>
        </div>
    </div>
    <div class="panel">
        <div class="panel-body">
            <table class="table table-bordered table-hover dataTable table-striped width-full text-nowrap"
                   id="dataTableExample">
                <thead>
                <tr>
                    <th>编码</th>
                    <th>名称</th>
                    <th>描述</th>
                    <th>导入日期</th>
                    <th>操作</th>
                </tr>
                </thead>
            </table>
        </div>
    </div>
</div>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog" >
    <form class="modal-content" enctype="multipart/form-data" id='myupload' method="post"  action="/other/methodological/upload" >
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="关闭" ><span aria-hidden="true">×</span></button>
            <h4 class="modal-title" >文件上传</h4>
        </div>
        <div class="modal-body">

            <div class="row">
                <div class="control-label" >文件上传</div>
                <div class="example">
                    <input type="file" name="fileupload" class="form-control" id="uploda"  >
                </div>

            </div>
            <div class="row">
                <div class="control-label" >文件图片</div>
                <div class="example">
                    <input type="file" name="fileupload1" class="form-control" id="img"  >
                </div>

            </div>
            <div class="row">
                <div class="control-label" >描述</div>
                <div class="example">
                    <input type="text" class="form-control" id="describe" name="describe" placeholder="文件描述">
                </div>

            </div>
            <div class="form-group">
                <input type="submit" class="btn btn-primary" />
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </form>
</div></div>
<script type="text/javascript">
    var $table = null;
    function gosubmit() {
        $("#myupload").ajaxSubmit({
            dataType :'json',//返回数据类型
            success:function(data){//图片上传成功时
                //获取服务器端返回的文件数据
                alert(data.name+","+data.pic+","+data.size);
            },
            error:function(xhr){
                btn.html(上传失败);
                bar.width('0');
                files.html(xhr.responseText);
            }
        });
    }
   
    function change() {
        $table.ajax.reload();
    }

    function delMethod(data) {
        $.ajax({
            url: "#springUrl('/other/methodological/delData')",
            data: {"id": data},
            type: "POST",
            success: function (text) {
                $table.ajax.reload();
            }
        })
    }
    $(function () {
        $table = $('#dataTableExample').DataTable($.po('dataTable', {
            "processing": true,
            "serverSide": true,
            "ordering": false,
            "columns": [
                {"data": "id"},
                {"data": "name"},
                {"data": "describe"},
                {"data": "createTime"},
                {"data": "id"},
            ], "columnDefs": [{
                "render": function (data, type, row) {
                    return Date.format(new Date(data), "yyyy-MM-dd hh:mm:ss");
                },
                "targets": 3
            },{
                "render": function (data, type, row) {
                    return "<button type='button' class='btn btn-block btn-danger' onclick='delMethod("+data+")'>删除</button> "
                },
                "targets": 4
            }],
            "ajax": "/other/methodological/getData/",
            "dom": '<"dt-dom-toolbar">rt<"bottom"pi>',
            "fnServerData": function (sSource, aoData, fnCallback) {
                var params = [
                    {name: "size", value: aoData[4].value}, {
                        name: "current", value: aoData[3].value / aoData[4].value + 1
                    }];
                $.ajax({
                    "dataType": 'json',
                    "type": "post",
                    "url": "/other/methodological/getData",
                    "data": params,
                    "success": fnCallback
                });
            }
        }));


        $("div.dt-dom-toolbar").append('<a class="btn btn-success margin-bottom-15 margin-left-15" data-toggle="modal" data-target="#myModal" ><i class="icon wb-edit" aria-hidden="true"></i>上传文件</a>');
        function reloadData() {
            $table.ajax.reload();
        }
    });

</script>